home *** CD-ROM | disk | FTP | other *** search
/ Totally AMOS / Totally AMOS - Issue 1 (1991-11)(Tucker, Len - Tucker, Anne).adf / programming / prog_hint.seq < prev    next >
Text File  |  1991-09-02  |  7KB  |  160 lines

  1.  157
  2. aaa00000ff00fe0080333fff001
  3. ^2()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
  4.  
  5.                 ^6[5HINTS & TIPS FOR BETTER PROGRAMMING.[0
  6.  
  7. ^2()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
  8.  
  9. ^7 Please  note  that  most  of  the tips & hints are for Amos V1.3 and
  10. ^7above.   To  get  the  best from Amos, and avoid a lot of programming
  11. ^7problems,  it  is  important to update to the latest version of AMOS.
  12. ^7This  is  always  available from:-
  13.  
  14. ^2DEJA VU SOFTWARE,
  15. ^2C/O SANDRA SHARKEY
  16. ^225, PARK ROAD,
  17. ^2WIGAN WN6 7AA.
  18.  
  19. ^7.....................................................................
  20.  
  21. ^2 This tip sounds good, but we haven't been able to test it yet, we'll
  22. ^2let you know what happens in the next issue.
  23.  
  24. ^6  Sometimes  when you are writing a program, one procedure can slow
  25. ^6the  whole  program  down.   We  have  heard that you can compile a
  26. ^6single procedure then run it from a Basic listing.  This will speed
  27. ^6up an otherwise slow part of your listing.
  28.  
  29. ^7.....................................................................
  30.  
  31. ^4 We  hope  that  the  next tip will help you avoid a major problem we
  32. ^4came across when we first started using the Compiler, we hope it will
  33. ^4save  you  the  frustration  we've  suffered  over the last couple of
  34. ^4months!
  35.  
  36. ^6 Most  of  our  programs  have  needed  a random number generator for
  37. ^6various  reasons,  and  we  have  been using the same one without any
  38. ^6problems......until  the  Compiler came along.  A problem was spotted
  39. ^6when  we  were  beta testing the compiler, none of our programs would
  40. ^6compile,  whereas  most other programs did.  We didn't know why for a
  41. ^6long time.
  42.  
  43. ^6 The problem got really frustrating when Marvin The Martian needed to
  44. ^6be  compiled  in  order  to  get  better  gameplay  & speed.  It kept
  45. ^6crashing after just a minute or two.
  46.  
  47. ^4 The  answer  came  by  chance while working on another program.  The
  48. ^4only  thing  that all our problem programs have in common is that the
  49. ^4random routine uses the RND command inside a loop.
  50.  
  51. ^2 It seems that the compiler does not accept the program if it loops
  52. ^2around the Rnd command.
  53.  
  54. ^7.....................................................................
  55.  
  56. ^6 If you have come across any problems like this where things work OK
  57. ^6in  Basic, but  not when compiled, let us know, even if you have not
  58. ^6found the answer!!
  59.  
  60. ^4 If you haven't got you copy of The AMOS Compiler as yet, why not try
  61. ^4our competition?  It's  easy to enter,  we give  you all the answers,
  62. ^4you just have to pick it out from the choice of three  we've given!
  63. ^7...................................................................
  64.  
  65.                 ^6{7USING THE RAM DISK IN YOUR PROGRAMS.{
  66.  
  67.                         ^4[5Help given by ^2SPARX.[0
  68.  
  69.  
  70. ^2[5WHAT IS A RAM DISK?[0
  71.  
  72. ^1 A  Ram  Disk  can be used in the same way as a floppy disk, with the
  73. ^1following differences.
  74.  
  75. ^21.  ^7As will be explained later, a ram disk is dynamic, it is only the
  76. ^7size  that  is  needed,  ie if you save a small file to ram, the disk
  77. ^7will  not  have  any wasted space as you would have on a floppy disk.
  78. ^7For example, if the files you put onto ram come to 50,000 bytes, then
  79. ^7the ram disk will be 50,000 bytes, no waste!
  80.  
  81. ^22.   ^7The data is stored in Fast mem, not in a drive, so that there is
  82. ^7a great advantage to storing graphic data.
  83.  
  84. ^23.  ^7Data stored on a ram drive, will NOT survive a guru or a reset as
  85. ^7data on a floppy does.
  86.  
  87. ^6 This  tip is only relevant if you are writing programs for users who
  88. ^6have ^21 meg or more.  ^5It will [2NOT [0work in a 1/2 meg machine.
  89.  
  90. ^4 Using  a  ram  disk is a great way to store your graphic data during
  91. ^4the  run  time of your program as you will not have to wait while the
  92. ^4new graphics are loaded in.
  93.  
  94. ^6 This I have done several times in the past with great sucess, if you
  95. ^6wish to try this out, then read on!
  96.  
  97. ^1 First  make sure that the ram handler and the ram device are on your
  98. ^1AMOS disk, to check, look in the devs and l directories.  If they are
  99. ^1missing,  then  copy  them from your workbench disk into the relevant
  100. ^1directories, not forgetting that these files will also have to be on
  101. ^1the disk that holds your finished program!
  102.  
  103. ^2 Once  you  have  checked  for these files, it is very easy to create
  104. ^2your ram disk.
  105.  
  106. ^5 You can do this either from the cli, or directly from AMOS itself.
  107.  
  108. ^7 To  do  so  inside  AMOS,  all  you  have  to do is put in this line
  109. ^7somewhere inside your initialisation routine.
  110.  
  111.                           ^2RM=Exist("ram:")
  112.  
  113. ^7 It's as simple as that!
  114.  
  115. ^2 When  AMOS  meets  this command, it looks at your disk to see if the
  116. ^2ram  handler  is available, if it is, it will create the ram disk for
  117. ^2you.   Once the ram disk is created, you can now load in your graphic
  118. ^2files  whatever  they  may be, screens, bob banks etc and immediately
  119. ^2they have been loaded save them to ram:  then delete the bank etc.
  120.  
  121.                           ^2eg Load"bobs.abk"
  122.                              ^2Save"ram:bobs.abk",1
  123.                              ^2Erase 1
  124.  
  125. ^5 Carry  on  like  this until all your graphic files are in ram.  Once
  126. ^5they are safely in ram, you can load each bank or screen etc as it is
  127. ^5needed  with  next  to no loss of time, it's almost as fast as a hard
  128. ^5drive.   I have used it sucessfully in several programs and it hasn't
  129. ^5let me down yet.
  130.  
  131. ^6 This  gives  the  illusion  that  all the graphics are in memory, as
  132. ^6there  will be no drive access, also that there are far more graphics
  133. ^6in memory than the machine is physically capable of handling.
  134.  
  135. ^7 There  are limits to how much can be put onto a ram disk, so keep an
  136. ^7eye on the byte size of your files.
  137.  
  138. ^2 Using  a  ram  disk will take a bit of experimenting, but it will be
  139. ^2worth it in the end when you think of the advantages.
  140.  
  141. ^4 An example of how a ram disk is used can be found in SHYMER, LPD 30.
  142. ^4This  is an illustrated adventure where the picture changes each time
  143. ^4you  move  to a new location.  Having seen the original version where
  144. ^4the  disk  access slowed things down no end, I suggested that the ram
  145. ^4disk  was  used,  the difference was amazing!  You can now ove around
  146. ^4from  place  to  place without waiting ages for the drive to catch up
  147. ^4with the game-play!
  148.  
  149. ^1 As  a  tip, while you are writing your program, REM or leave out the
  150. ^1save  to  ram until you have finished.  This is because leaving it in
  151. ^1will  cause  the  program  to  load your files and save them into ram
  152. ^1every  time you test your program, this will take up a lot of time if
  153. ^1you test your program frequently, as is normally the case.
  154.  
  155. ^2 If  you  have any problems, drop us a line and we'll see what we can
  156. ^2do!
  157.  
  158. ^6()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
  159. \
  160.